module top_module( 
    input [399:0] a, b,
    input cin,
    output cout,
    output [399:0] sum );

    wire	[99:0]	cout_temp;
    
    assign cout = cout_temp[99];
    
    genvar i;
    generate
        for(i = 0; i < 100; i++) begin:block1
            if(i == 0) begin
               bcd_fadd u_bcd_fadd_0(
                   	.a(a[3:0]),
                   	.b(b[3:0]),
                	.cin(cin),
                	.cout(cout_temp[0]),
                   	.sum(sum[3:0])
            	); 
            end
            else begin
               bcd_fadd u_bcd_fadd_0(
                   .a(a[4*i+3:4*i]),
                   	.b(b[4*i+3:4*i]),
                   	.cin(cout_temp[i-1]),
                   	.cout(cout_temp[i]),
                   	.sum(sum[4*i+3:4*i])
            	); 
            end
        end
    endgenerate
    
endmodule
